import ajax from './ajax'
 
//http://demo.itlike.com/web/xlmc/api/homeApi
//http://demo.itlike.com/web/xlmc/api/homeApi/categories
//http://demo.itlike.com/web/xlmc/api/homeApi/categoriesdetail/lk001
//  lk001-lk006

//1.定义基础路径
const BASE_URL = 'http://demo.itlike.com/web/xlmc';

export const getHomeData = ()=>ajax(BASE_URL+ '/api/homeApi');
export const getCategories = ()=>ajax(BASE_URL+ '/api/homeApi/categories');
export const getCategoriesDetail = (preParams)=>ajax(BASE_URL+ '/api/homeApi/categoriesdetail'+preParams);

//2.用户中心接口
// http://demo.itlike.com/web/xlmc/api/send_code
const LOCAL_BASE_URL = 'http://demo.itlike.com/web/xlmc';
//2.1获取短信验证码(GET)
//export const getPhoneCode = (phone) =>ajax(LOCAL_BASE_URL + '/api/send_code',{phone});
//2.2手机验证码登录(POST)
//export const phoneCodeLogin = (phone,code) => ajax(LOCAL_BASE_URL+'/api/login_code',{phone,code},'POST');
//2.3用户名和密码登录(POST)
//export const pwdLogin = (user_name,user_pwd,captcha) => ajax(LOCAL_BASE_URL+'/api/login_pwd',{user_name,user_pwd,captcha},'POST');
//2.4 自动登录
export const getUserInfo = ()=>ajax(LOCAL_BASE_URL+'/api/userinfo');
//2.5 退出登录
export const getLogOut = ()=>ajax(LOCAL_BASE_URL+'/api/logout');

//3. 购物车接口
/* 
3.1 添加商品
请求方式：POST
参数：{goods_id:String,goods_name:String,goods_price:Number,samll_image:String}
*/
//export const addGoodsToCart = (goods_id,goods_name,goods_price,samll_image)=>ajax(LOCAL_BASE_URL+'/api/cart/add',{goods_id,goods_name,goods_price,samll_image},'POST');

// //3.2 获取当前用户购物车中的商品
// export const getGoodsCart = (user_id) => ajax(LOCAL_BASE_URL+'/api/cart/search'+user_id);

// //3.3 修改购物车商品数量
// export const changeCartNum = (user_id,goods_id,type) => (LOCAL_BASE_URL+'/api/cart/num',{user_id,goods_id,type},'POST');

// //3.4删除当前用户购物车中的所有商品
// export const clearAllCart =(user_id)=>ajax(LOCAL_BASE_URL+'/api/cart/clear/'+user_id);

export const getWjs =()=>ajax('http://www.bs.com/public/index.PHP/test/index/api');
export const pwdLogin =(username,password)=>ajax('http://www.bs.com/public/index.PHP/test/index/pwdLogin',{username,password});


//获得根据销售类型分类的蔬菜和根据品种类型分类的蔬菜
export const getVegetables=()=>ajax('http://www.bs.com/public/index.PHP/api/index/getVegetables');
//获取短信验证码
export const getPhoneCode = (phone) =>ajax('http://www.bs.com/public/index.PHP/api/index/getPhoneCode',{phone});
//手机验证码登录
export const phoneCodeLogin = (phone,code) => ajax('http://www.bs.com/public/index.PHP/api/index/phoneCodeLogin',{phone,code});
//添加商品到购物车
export const addGoodsToCart = (token,vid,vname,price,pzleixing)=>ajax('http://www.bs.com/public/index.PHP/api/index/addGoodsToCart',{token,vid,vname,price,pzleixing});
//删除购物车的商品
export const removeOutCart = (token,goodsId) =>ajax('http://www.bs.com/public/index.PHP/api/index/removeOutCart',{token,goodsId});
//删除当前用户购物车中的所有商品
export const clearAllCart =(token)=>ajax('http://www.bs.com/public/index.PHP/api/index/clearAllCart',{token});
// 获取当前用户购物车中的商品
export const getGoodsCart = (token) =>ajax('http://www.bs.com/public/index.PHP/api/index/getGoodsCart',{token});
//根据手机号码去用户表查询该手机号码是否已经被注册
export const verifyPhone = (phone) =>ajax('http://www.bs.com/public/index.PHP/api/index/verifyPhone',{phone});
//根据账号去用户表查询该账号是否已经被注册
export const verifyZhangHao = (zhanghao) =>ajax('http://www.bs.com/public/index.PHP/api/index/verifyZhangHao',{zhanghao});
//注册用户
export const regist = (username,zhanghao,password,phone) =>ajax('http://www.bs.com/public/index.PHP/api/index/regist',{username,zhanghao,password,phone});
//生成鲜活密码柜
export const getxhgui = (zhanghao)=>ajax('http://www.bs.com/public/index.PHP/api/index/getxhgui',{zhanghao});
//生成一般密码柜
export const getybgui = (zhanghao)=>ajax('http://www.bs.com/public/index.PHP/api/index/getybgui',{zhanghao});
//手机号码验证码登录功能
export const savePhone = (phone)=>ajax('http://www.bs.com/public/index.PHP/api/index/savePhone',{phone});
//手机号码验证码登录判断用户是否被禁用
export const memberStatus = (phone)=>ajax('http://www.bs.com/public/index.PHP/api/index/memberStatus',{phone});
//创建支付订单
export const createyzfOrder = (token,beizhu,totalPrice,servicetime)=>ajax('http://www.bs.com/public/index.PHP/api/index/createyzfOrder',{token,beizhu,totalPrice,servicetime});
//创建待支付订单
export const createwzfOrder = (token,beizhu,totalPrice,servicetime)=>ajax('http://www.bs.com/public/index.PHP/api/index/createwzfOrder',{token,beizhu,totalPrice,servicetime});
//创建订单详情表
export const createdOrderDetail = (bianhao)=>ajax('http://www.bs.com/public/index.PHP/api/index/createdOrderDetail',{bianhao});
//购物车商品选中与取消
export const singerGoodsSelected = (token,goodsid)=>ajax('http://www.bs.com/public/index.PHP/api/index/singerGoodsSelected',{token,goodsid});
//全选
export const selectedAll = (token)=>ajax('http://www.bs.com/public/index.PHP/api/index/selectedAll',{token});
//取消全选
export const selectedNo = (token)=>ajax('http://www.bs.com/public/index.PHP/api/index/selectedNo',{token});
//订单列表
export const getOrders = (token)=>ajax('http://www.bs.com/public/index.PHP/api/index/getOrders',{token});
//删除订单
export const deleteOrder = (id)=>ajax('http://www.bs.com/public/index.PHP/api/index/deleteOrder',{id});
//订单支付时间
export const getPayTime = (bianhao)=>ajax('http://www.bs.com/public/index.PHP/api/index/getPayTime',{bianhao});
//订单付款
export const payOrder = (id)=>ajax('http://www.bs.com/public/index.PHP/api/index/payOrder',{id});
//生成积分记录
export const createJF = (token,bianhao,add,reduce)=>ajax('http://www.bs.com/public/index.PHP/api/index/createJF',{token,bianhao,add,reduce});
//订单生成，修改用户总积分数据
export const updateJF = (token,add,reduce)=>ajax('http://www.bs.com/public/index.PHP/api/index/updateJF',{token,add,reduce});
//根据输入的蔬菜名模糊搜索
export const getSearch = (vname)=>ajax('http://www.bs.com/public/index.PHP/api/index/getSearch',{vname});
//获取用户信息
export const getUser = (token)=>ajax('http://www.bs.com/public/index.PHP/api/index/getUser',{token});
//查询用户名是否存在
export const getUserByName = (name)=>ajax('http://www.bs.com/public/index.PHP/api/index/getUserByName',{name});
//更改用户名字
export const UpdateUserName = (token,name)=>ajax('http://www.bs.com/public/index.PHP/api/index/UpdateUserName',{token,name});
//查询账号是否存在
export const getUserByZH = (zhanghao) =>ajax('http://www.bs.com/public/index.PHP/api/index/getUserByZH',{zhanghao});
//更改用户账号
export const UpdateUserZH = (token,zhanghao) =>ajax('http://www.bs.com/public/index.PHP/api/index/UpdateUserZH',{token,zhanghao});
//判断旧密码是否正确
export const getUserByPasswd = (token,oldpasswd) =>ajax('http://www.bs.com/public/index.PHP/api/index/getUserByPasswd',{token,oldpasswd});
//更改用户密码
export const UpdatePasswd = (token,newpasswd)  =>ajax('http://www.bs.com/public/index.PHP/api/index/UpdatePasswd',{token,newpasswd});
//查询手机号码是否存在
export const getUserByPhone=(phone)=>ajax('http://www.bs.com/public/index.PHP/api/index/getUserByPhone',{phone});
//更改手机号码
export const UpdateUserPhone=(token,mobile)=>ajax('http://www.bs.com/public/index.PHP/api/index/UpdateUserPhone',{token,mobile});
//获取鲜活密码柜账号，密码
export const getXH = (uid)=>ajax('http://www.bs.com/public/index.PHP/api/index/getXH',{uid});
//获取一般密码柜账号，密码
export const getYB = (uid)=>ajax('http://www.bs.com/public/index.PHP/api/index/getYB',{uid});
//申请采购员成功
export const tobeCGY = (uid)=>ajax('http://www.bs.com/public/index.PHP/api/index/tobeCGY',{uid});
//前台获取采购列表信息
export const getCaigou = ()=>ajax('http://www.bs.com/public/index.PHP/api/index/getCaigou');
//获取采购详情
export const getCaigouDetail = (bianhao,token)=>ajax('http://www.bs.com/public/index.PHP/api/index/getCaigouDetail',{bianhao,token});
//申请采购
export const shenqingCG = (bianhao,caigouyuan)=>ajax('http://www.bs.com/public/index.PHP/api/index/shenqingCG',{bianhao,caigouyuan});
//获取我的采购列表数据
export const getMyCaigou = (token)=>ajax('http://www.bs.com/public/index.PHP/api/index/getMyCaigou',{token});
//订单详情页面
export const getDetail = (bianhao)=>ajax('http://www.bs.com/public/index.PHP/api/index/getDetail',{bianhao});

//确认收货
export const queren = (bianhao)=>ajax('http://www.bs.com/public/index.PHP/api/index/queren',{bianhao});
//待支付订单
export const getDzfOrders = (token)=>ajax('http://www.bs.com/public/index.PHP/api/index/getDzfOrders',{token});
//待支付订单
export const getDfhOrders = (token)=>ajax('http://www.bs.com/public/index.PHP/api/index/getDfhOrders',{token});
//已发货订单
export const getYfhOrders = (token)=>ajax('http://www.bs.com/public/index.PHP/api/index/getYfhOrders',{token});
//已完成订单
export const getYwcOrders = (token)=>ajax('http://www.bs.com/public/index.PHP/api/index/getYwcOrders',{token});




